using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Data.SqlClient;


/// <summary>
/// Summary description for LoaiMonHocDAO
/// </summary>
public class LoaiMonHocDAO:DataProvider
{
	public LoaiMonHocDAO()
	{
		//
		// TODO: Add constructor logic here
		//
	}    
    public ArrayList LayMang_LoaiMon()
    {
        connect();
        ArrayList arr = new ArrayList();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Select_LoaiMonHoc", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                LoaiMonHocDTO loaimondto = new LoaiMonHocDTO();
                loaimondto.MaLoai = dr.GetInt32(0);
                loaimondto.TenLoai = dr.GetString(1);
                arr.Add(loaimondto);
            }
        }
        catch(Exception e )
        {
            throw e;
        }
        return arr;
    }
    public LoaiMonHocDTO getLoaiMon(int ma)
    {
        connect();
        LoaiMonHocDTO loaimondto = new LoaiMonHocDTO();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Select_LoaiMonHocTheoMa", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@maLoaiMon", SqlDbType.Int);
            cmd.Parameters["@maLoaiMon"].Value = ma;
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                
                loaimondto.MaLoai = dr.GetInt32(0);
                loaimondto.TenLoai = dr.GetString(1);
                
            }
        }
        catch (Exception e)
        {
            throw e;
        }
        return loaimondto;
    }
}
